import { mapState } from 'vuex'
import Footer from '@/components/footer/footer.vue'
export default {
    components: {
        Footer
    },
    data() {
        return {
            title: [],
            modTitle: [],
            banner: '',
            goods: {},
            isActive: 0 // 当前选中
        }
    },
    computed: {
        ...mapState(['allOtherData', 'otherData'])
    },
    created() {
        this.initData()
    },
    methods: {
        initData() {
            this.$store.dispatch('getAllOtherData')
        },
        changeActive(index) { // 选中
            this.isActive = index
            this.getOtherData(index)
        },
        getOtherData(index) {
            this.$store.state.otherDataName = this.title[index]
            this.$store.dispatch('getOtherData')
        }
    },
    watch: {
        allOtherData: function (value) {
            if (value) {
                this.title = Object.keys(value)
                Object.values(value).forEach((val, index) => {
                    this.modTitle.push(val.modTitle)
                    console.log(index)
                });
                this.getOtherData(0)
            }
        },
        otherData: function (value) {
            if (value) {
                this.goods = value.modCon
                this.banner = value.banner
            }
        }
    }
}